﻿// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.

// Write your JavaScript code.

//可将表单序列化为Json对象
$.fn.serializeJson = function () {
    var jsonObject = {};
    var array = this.serializeArray();
    for (var i = 0; i < array.length; i++) {
        var obj = array[i];
        jsonObject[obj.name] = trim(obj.value);
    }
    return jsonObject;
}

function trim(val) {
    if (val) {
        return val.replace(/(^\s*)|(\s*$)/g, "");
    } else {
        return val;
    }
}